<?php
namespace app\controller;

use app\BaseController;

class UserLogin extends BaseController
{
    /**
     * 加密token
     * @param $uid
     * @return string
     */
    public function makeToken($uid){
        $str = md5($uid.time().md5(time()));
        return $str;
    }

    /**
     * 用户登录时 返回token，并返回用户某些信息
     * @param $uid
     * @param $userData
     */
    public function loginData($uid,$userData){
        $token = $this->makeToken($uid);
        $resultData = [
            'id'            => $userData['id'],
            'username'      => $userData['username'],
            'sex'           => $userData['sex'],
            'phone'         => $userData['phone'],
            'email'         => $userData['email'],
            'jurisdiction'  => $userData['jurisdiction']
        ];
        app('mycache')->set($token,json_encode($resultData),86400);
    }
}